//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package cn.com.crc.ems.rest.common;

import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class Result implements Serializable {
    private static final long serialVersionUID = 4368628781658521985L;
    public static final String SUCCESS = "0";
    public static final String FAILURE = "-1";
    public static final String ENQUIRY = "2";
    @ApiModelProperty(
        value = "返回结果代码",
        example = "0：成功；-1：失败；2: 咨询"
    )
    private String code;
    @ApiModelProperty(
        value = "返回结果提示消息",
        example = "成功提示消息或异常提示消息"
    )
    private String msg;
    @ApiModelProperty(
        value = "返回结果",
        example = "不同业务返回字段不同，可能为空"
    )
    private Object obj;
    @ApiModelProperty(
        value = "返回列表",
        example = "不同业务返回字段不同，可能为空"
    )
    private List resultlist;
    @ApiModelProperty(
        value = "返回错误异常堆栈",
        example = "返回错误异常堆栈"
    )
    private String detailErrorMsgStack;
    @ApiModelProperty(
        value = "页面提交token",
        example = "用于返回token到页面"
    )
    private String submitValidateToken;

    public Result() {
        this("0", "");
    }

    public Result(Object results) {
        this("0", results);
    }

    public Result(String msg) {
        this("0", msg);
    }

    public Result(String code, Object results) {
        this.resultlist = new ArrayList();
        this.code = code;
        this.obj = results;
    }

    public Result(String code, String msg) {
        this.resultlist = new ArrayList();
        this.code = code;
        this.msg = msg;
    }

    public Result(String code, List list) {
        this.resultlist = new ArrayList();
        this.code = code;
        this.resultlist = list;
    }

    public Result(String code, Object results, String msg) {
        this.resultlist = new ArrayList();
        this.code = code;
        this.obj = results;
        this.msg = msg;
    }

    public static Result makeSuccess() {
        return new Result();
    }

    public static Result makeSuccess(String msg) {
        return new Result(msg);
    }

    public static Result makeSuccess(Object results, String msg) {
        return new Result("0", results, msg);
    }

    public static Result makeFail(String msg) {
        return new Result("-1", msg);
    }

    public static Result makeFailWithCode(String code , String msg) {
        return new Result(code, msg);
    }

    public static Result makeFail(Object results, String msg) {
        return new Result("0", results, msg);
    }

    public Boolean isSucess() {
        return Objects.equals("0", this.code);
    }

    public Boolean isFail() {
        return !this.isSucess();
    }

    public static Result showConfirmMsg(String msg) {
        return new Result("2", msg);
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getCode() {
        return this.code;
    }

    public Object getObj() {
        return this.obj;
    }

    public void setObj(Object obj) {
        this.obj = obj;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public List getResultlist() {
        return this.resultlist;
    }

    public void setResultlist(List resultlist) {
        this.resultlist = resultlist;
    }

    public String getDetailErrorMsgStack() {
        return this.detailErrorMsgStack;
    }

    public void setDetailErrorMsgStack(String detailErrorMsgStack) {
        this.detailErrorMsgStack = detailErrorMsgStack;
    }

    public String getSubmitValidateToken() {
        return this.submitValidateToken;
    }

    public void setSubmitValidateToken(String submitValidateToken) {
        this.submitValidateToken = submitValidateToken;
    }

    public Result(ResultEnums resultEnums) {
        this.resultlist = new ArrayList();
        this.code = resultEnums.getCode();
        this.msg = resultEnums.getMsg();
    }

    public Result(ResultEnums type, Object data) {
        this.resultlist = new ArrayList();
        this.code = type.getCode();
        this.msg = type.getMsg();
        this.obj = data;
    }

    public Result(String code, String msg, Object data, List list) {
        this.resultlist = new ArrayList();
        this.code = code;
        this.msg = msg;
        this.obj = data;
        this.resultlist = list;
    }

    public Result(ResultEnums type, Object data, List list) {
        this.resultlist = new ArrayList();
        this.code = type.getCode();
        this.msg = type.getMsg();
        this.obj = data;
    }

    public Result(String code, String msg, Object data) {
        this.resultlist = new ArrayList();
        this.code = code;
        this.msg = msg;
        this.obj = data;
    }
}
